package com.neu.icloud.controller;

import java.time.LocalDate;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.icloud.entity.Plan;
import com.neu.icloud.service.PlanService;

@RestController
@RequestMapping("/PlanController")
public class PlanController {

	@Autowired
	private PlanService planService;
	
	//全查
	@RequestMapping("/listPlan")
	public List<Plan> listPlan()throws Exception{
		return planService.listPlan();
	}
	//查询产品名称
	@RequestMapping("/selectByPlanId")
	public String selectByPlanId(Integer planId) throws Exception{
		return planService.selectByPlanId(planId);
	}
	
	//根据计划状态查询
	@RequestMapping("/listPlanByState")
	public List<Plan> listPlanByState(String planState) throws Exception{
		return planService.listPlanByState(planState);
	}
	
	//按id查询
	@RequestMapping("/listPlanById")
	public List<Plan> listPlanById(Plan plan) throws Exception {
		return planService.listPlanById(plan.getOrderId());
	}

	//新增计划
	@RequestMapping("/savePlan")
	public int savePlan(Plan plan) throws Exception {
		return planService.savePlan(plan);
	}

	//启动计划
	@RequestMapping("/updatePlan")
	public int updatePlan(Plan plan) throws Exception {
		return planService.updatePlan(plan);
	}
	//删除计划
	@RequestMapping("/removePlan")
	public int removePlan(Integer planId) throws Exception {
		return planService.removePlan(planId);
	}
	
	//修改计划状态
	@RequestMapping("/updatePlanState")
	public int updatePlanState(Integer planId) throws Exception{
		return planService.updatePlanState(planId);
	}
}
